import java.util.ArrayList;

public class two_digitplus {

   import java.util.*;
import java.util.ArrayList;

        public ArrayList<Integer> FindNumbersWithSum(int [] array,int sum) {
            int left = 0;
            int right = array.length-1;
            ArrayList<Integer> arr = new ArrayList<>();
            while(left<right){
                if(array[left]+array[right]<sum){
                    left++;
                }
                else if(array[left]+array[right]>sum){
                    right--;
                }
                else{
                    arr.add(array[left]);
                    arr.add(array[right]);
                    break;
                }
            }
            return arr;
        }

}
